package com.id.coinscleaner.viewmodel

import androidx.lifecycle.ViewModel
import com.id.coinscleaner.App.Companion.appContext
import com.id.coinscleaner.bean.ScaredItem

/**
 * Created by YiGo on 2022/7/12.
 */
class ScaredViewModel : ViewModel() {
    var scareData = mutableListOf<ScaredItem>()

    fun initScaredData() {
        val allApps = appContext.packageManager.getInstalledApplications(0)
        val count = if (allApps.size > 30) 30 else allApps.size
        (0 until count).forEach {
            if (it <= count && (it == 3 || it == 15 || it == 10 || it == 20 || it == 30)) {
                scareData.add(
                    ScaredItem(
                        allApps[it].packageName,
                        true
                    )
                )
            } else {
                scareData.add(
                    ScaredItem(
                        allApps[it].packageName,
                        false
                    )
                )
            }
        }
    }
}